package com.phantom.js;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.MutableCapabilities;

import com.seleninum.Junit.App;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class JunitTest extends TestCase{
	private PhantomJSDriver  driver;
	WebDriver webDriver = null;
	
	 /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite(JunitTest.class );
    }

    public void setUp() throws Exception {
    	//设置必要参数
        MutableCapabilities desiredCapabilities = new MutableCapabilities();
        //ssl 证书支持
//        desiredCapabilities.setCapability("acceptSslCerts",true);
        //截屏支持
        desiredCapabilities.setCapability("takesScreenshot",false);
        //css 搜索支持
        desiredCapabilities.setCapability("cssSelectorsEnabled",true);
        //js 支持
//        desiredCapabilities.setJavascriptEnabled(true);
        //驱动支持
//        desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"E://phantomjs-1.9.2/phantomjs.exe");
       desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"E://phantomjs-2.1.1/bin/phantomjs.exe");

        //    	 System.setProperty("phantomjs.binary.path", "E://phantomjs-2.1.1/bin/phantomjs.exe");
         driver = new PhantomJSDriver(desiredCapabilities);
    
    }
	

    public void tearDown() throws Exception {
    }


    public void testSearch() throws InterruptedException {
    	 try {
    		 System.out.println("test-----start");
    		 Long starttime = System.currentTimeMillis();
//    		webDriver =webDriver .createPhantomjsWebDriver("D:/webdrvier/phantomjs-1.9.8-windows/phantomjs.exe");
//	        driver.get("www.baidu.com");
	        driver.get("http://2084w1u146.imwork.net:35904/");
	        
	        System.out.println(driver.getTitle());
	        Long endtime = System.currentTimeMillis();
	        System.out.println((endtime - starttime) + "test-----end");
    	   } catch (Exception e) {
    	        e.printStackTrace();
    	    }
        assertTrue(true);
        
    }
}
